﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VOL;
using BLL;
using System.Data;
using System.Data.SqlClient;

namespace WebShoes.Admin
{
    public partial class KhachHangInfoForm : System.Web.UI.Page
    {
        KhachHangBL _KhachHangBL = new KhachHangBL();
        int MaKhachHang = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string _MaKhachHang = Request.QueryString["MaKhachHang"];
                if (_MaKhachHang == null || _MaKhachHang == "" || !int.TryParse(_MaKhachHang, out MaKhachHang))
                {
                    hdfMaKhachHang.Value = "0";
                }
                else
                {
                    DataTable dtKH = _KhachHangBL.getTongTien(MaKhachHang);
                    
                    ThanhPhoBL _ThanhPhoBL = new ThanhPhoBL();
                    DataTable dtTP = _ThanhPhoBL.searchIDThanhPho(int.Parse(dtKH.Rows[0]["MaThanhPho"].ToString()));

                    QuanHuyenBL _QuanHuyenBL = new QuanHuyenBL();
                    DataTable dtQH = _QuanHuyenBL.searchIDQuanHuyen(int.Parse(dtKH.Rows[0]["MaQuanHuyen"].ToString()));

                    lblMaKhachHang.Text = _MaKhachHang;
                    //lblTenDangNhap.Text = dtKH.Rows[0]["TenDangNhap"].ToString();
                    lblDiaChi.Text = dtKH.Rows[0]["DiaChi"].ToString();
                    lblEmail.Text = dtKH.Rows[0]["Email"].ToString();
                    lblDienThoai.Text = dtKH.Rows[0]["DienThoai"].ToString();
                    lblDienThoaiDiDong.Text = dtKH.Rows[0]["DienThoaiDiDong"].ToString();
                    lblHoTenKhachHang.Text = dtKH.Rows[0]["HoTenKhachHang"].ToString();
                    lblQuanHuyen.Text = dtQH.Rows[0]["TenQuanHuyen"].ToString();
                    lblThanhPho.Text = dtTP.Rows[0]["TenThanhPho"].ToString();
                    lblTongTien.Text = dtKH.Rows[0]["TongTien"].ToString();
                    hdfMaKhachHang.Value = _MaKhachHang;
                }
            }
        }
    }
}